<?php

namespace app\adminapi\export;

use app\adminapi\controller\v1\finance\Finance;
use app\model\finance\FinanceStatistic;
use app\services\user\UserBillServices;
use Carbon\Carbon;

class FinanceStatisticExport extends BaseExport
{
    protected $header = [
        '交易时间', '交易单号', '交易类型', '收支类型', '摘要', '交易金额(元)'
    ];

    public function createData(array $where)
    {
        $list = app()->make(UserBillServices::class)->getStatisticList($where)['list'];

        $data = [];

        foreach ($list as $item) {
            $data[] = [
                $item['trade_time'] ?? '',
                $item['sn'] ?? '',
                $item['trade_type_text'] ?? '',
                $item['amount_type_text'] ?? '',
                $item['remark'] ?? '',
                $item['amount_text'] ?? ''
            ];
        }
        return $data;
    }
}